class Solution
{
public:
    int countPoints(string rings)
    {
        int n = rings.size() / 2;
        vector<int> R(10), G(10), B(10);
        for (int i = 0; i < n; ++i)
        {
            int ring = rings[2 * i + 1] - '0';
            char color = rings[2 * i];
            if (color == 'R')
            {
                ++R[ring];
            }
            else if (color == 'G')
            {
                ++G[ring];
            }
            else
            {
                ++B[ring];
            }
        }
        int result = 0;
        for (int i = 0; i < 10; ++i)
        {
            if (R[i] && G[i] && B[i])
            {
                ++result;
            }
        }
        return result;
    }
};